import numpy as np
from numpy.linalg import *


def main():
    lst = [[1, 3, 5], [2, 4, 6]]
    print(type(lst))
    np_lst = np.array(lst)
    print(type(np_lst))
    np_lst = np.array(lst, dtype=np.float)
    print(np_lst.shape)
    print(np_lst.ndim)
    print(np_lst.dtype)
    print(np_lst.itemsize)
    print(np_lst.size)

    # 2 Some Arrays
    print(np.zeros([2, 4]))
    print(np.ones([3, 5]))
    print("Rand:")
    print(np.random.randn(2, 3))
    print("RandInt:")
    print(np.random.randint(1, 10, 3))
    print("Randn:")
    print(np.random.randn())
    print(np.random.randn(2, 4))
    print("Choice:")
    print(np.random.choice([10, 20, 30, 2, 8]))
    print("Distribuite:")
    print(np.random.beta(1, 10, 100))

    # 3 Array Opes
    lst = np.arange(1, 11).reshape([2, -1])
    print(np.exp(lst))
    print(np.exp2(lst))
    print(np.sqrt(lst))
    print(np.sin(lst))
    print(np.log(lst))

    lst = np.array([
                  [[1, 2, 3, 4],
                   [4, 5, 6, 7]],
                  [[7, 8, 9, 10],
                   [10, 11, 12, 13]],
                  [[14, 15, 16, 17],
                   [18, 19, 20, 21]]
                  ])
    print(lst.sum())
    print(lst.sum(axis=0))
    print(lst.sum(axis=1))
    print(lst.sum(axis=2))
    print(lst.max())
    print(lst.max(axis=1))
    print(lst.min())
    print(lst.min(axis=0))

    lst1 = np.array([10, 20, 30, 40])
    lst2 = np.array([4, 3, 2, 1])
    print("Add:",lst1+lst2)
    print("Sub:",lst1-lst2)
    print("Mul:",lst1*lst2)
    print("Div:",lst1/lst2)
    print("Square:",lst1**2)
    print(np.dot(lst1.reshape([2,2]),lst2.reshape([2, 2])))

    print(np.eye(3))
    lst=np.array([[1, 2],
                  [3, 4]])
    print(inv(lst))
    print(lst.transpose())
    print(det(lst))
    print(eig(lst))
    y = np.array([[5.], [7.]])
    print(solve(lst,y))

    print(np.poly1d([4, 4, 4, 4]))
    print(np.identity(4))

    x = np.arange(6)
    x = x.reshape(2, 3)
    print(x)
    print(np.ones_like(x))


if __name__=="__main__":
    main()